package com.dai.zhenfujin.visitingcard.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.dai.zhenfujin.R;
import com.dai.zhenfujin.base.BaseActivity;
import com.dai.zhenfujin.visitingcard.adapter.VisitingCardAdapter;
import com.dai.zhenfujin.visitingcard.bean.VisitingCardBean;

import java.util.ArrayList;
import java.util.List;

/**
 * 车页面
 */
public class VehicleActivity extends BaseActivity implements View.OnClickListener{
    private TextView tvName;
    private ImageView imageView;
    private ListView listView;
    private View view;
    
    private List<VisitingCardBean> beanList;
    private VisitingCardAdapter adapter;

    private TextView tvNewCar,tvUsedCar,tvMaintenance,tvInsurance,tvSchool,tvCarWash,tvPenalty;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_vehicle);
        view=View.inflate(this,R.layout.vehicle_listview_head,null);
        
        initView();
        initListener();

        beanList = new ArrayList<>();
        for (int  j=0; j<20;j++){
            beanList.add(new VisitingCardBean(
                    "张艺兴","总监","100米","张艺兴工作室集团",
                    "张艺兴工作室","120万起","住宅 | 洪山 | 洪山其他",
                    "光谷广场111号"));
        }
        listView.addHeaderView(view);
        adapter = new VisitingCardAdapter(this,beanList);
        listView.setAdapter(adapter);
        listView.setVerticalScrollBarEnabled(false);
    }

    private void initListener() {
        imageView.setOnClickListener(this);
        tvNewCar.setOnClickListener(this);
        tvUsedCar.setOnClickListener(this);
        tvMaintenance.setOnClickListener(this);
        tvInsurance.setOnClickListener(this);
        tvSchool.setOnClickListener(this);
        tvCarWash.setOnClickListener(this);
        tvPenalty.setOnClickListener(this);

    }

    private void initView() {
        tvName = findViewById(R.id.title_textview);
        tvName.setText("车");
        imageView = findViewById(R.id.title_imageview);

        listView = findViewById(R.id.vehicle_listview);


        tvNewCar =view.findViewById(R.id.vehicle_newcar);
        tvUsedCar =view. findViewById(R.id.vehicle_usedcar);
        tvMaintenance =view. findViewById(R.id.vehicle_maintenance);
        tvInsurance = view.findViewById(R.id.vehicle_insurance);
        tvSchool= view.findViewById(R.id.vehicle_school);
        tvCarWash = view.findViewById(R.id.vehicle_car_wash);
        tvPenalty = view.findViewById(R.id.vehicle_penalty);

    }

    @Override
    public void onClick(View v) {

        switch (v.getId()){
            case R.id.title_imageview:
                finish();
                break;
            case R.id.vehicle_newcar://新车
                break;
            case R.id.vehicle_usedcar://二手车
                break;
            case R.id.vehicle_maintenance://维保
                break;
            case R.id.vehicle_insurance://车险
                break;
            case R.id.vehicle_school://驾校
                break;
            case R.id.vehicle_car_wash://洗车
                break;
            case R.id.vehicle_penalty://罚款代缴
                break;
        }
    }
}
